package restfuljobs

import static javax.ws.rs.core.MediaType.APPLICATION_XML
import static javax.ws.rs.core.Response.Status.FORBIDDEN 

import javax.ws.rs.WebApplicationException
import javax.ws.rs.core.Response

public class AccessDeniedException extends WebApplicationException {

	AccessDeniedException(def clazz, def id) {
        super(notFound(clazz, id))
    }
    
	private static Response notFound(def clazz, def id) {
        Response.status(FORBIDDEN).entity(notFoundMessage(clazz, id)).type(APPLICATION_XML).build()
    }
    
    private static String notFoundMessage(def clazz, def id) {
        "<error>Access denied to ${clazz.simpleName}</error>"
    }
}
